class code1 {
    //单调栈
    //每日温度
    public int[] dailyTemperatures(int[] temperatures) {
        int n = temperatures.length;
        int[] ans = new int[n];

        Stack<Integer> st = new Stack<>();

        for(int i=0;i<n;i++) {
            while(!st.isEmpty() && temperatures[i] > temperatures[st.peek()]) {
                int x = st.pop();//0下标
                ans[x] = i-x;
            }
            st.push(i);
        }

        return ans;
    }
}